package com.ruoyi.canteen.mapper;

import java.util.List;
import com.ruoyi.canteen.domain.CanteenCpClass;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

/**
 * 菜品分类Mapper接口
 * 
 * @author ruoyi
 * @date 2021-09-08
 */
public interface CanteenCpClassMapper 
{
    /**
     * 查询菜品分类
     * 
     * @param id 菜品分类主键
     * @return 菜品分类
     */
    public CanteenCpClass selectCanteenCpClassById(Long id);

    /**
     * 查询菜品分类列表
     * 
     * @param canteenCpClass 菜品分类
     * @return 菜品分类集合
     */
    public List<CanteenCpClass> selectCanteenCpClassList(CanteenCpClass canteenCpClass);

    /**
     * 新增菜品分类
     * 
     * @param canteenCpClass 菜品分类
     * @return 结果
     */
    public int insertCanteenCpClass(CanteenCpClass canteenCpClass);

    /**
     * 修改菜品分类
     * 
     * @param canteenCpClass 菜品分类
     * @return 结果
     */
    public int updateCanteenCpClass(CanteenCpClass canteenCpClass);

    /**
     * 删除菜品分类
     * 
     * @param id 菜品分类主键
     * @return 结果
     */
    public int deleteCanteenCpClassById(Long id);

    /**
     * 批量删除菜品分类
     * 
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteCanteenCpClassByIds(Long[] ids);

    /**
     * 通过门店ID，获取菜品分类列表
     * @param mdId 门店ID
     * @return
     */
    @Select("SELECT distinct c.id,c.md_id,c.`name`,c.order_no,c.must_flag from canteen_cp_class as c " +
            "LEFT JOIN canteen_cp_class_relation as r on c.id = r.class_id " +
            "where delete_flag=0 and md_id = #{mdId} " +
            "order by order_no ASC;")
    @Results({
            @Result(property = "id", column = "id"),
            @Result(property = "mdId", column = "md_id"),
            @Result(property = "name", column = "name"),
            @Result(property = "orderNo", column = "order_no"),
            @Result(property = "mustFlag", column = "must_flag"),
    })
    public List<CanteenCpClass> selectCpClassListByMdId(@Param("mdId") Integer mdId);

}
